package com.cens.mall.seckill.scheduled;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @EnableScheduling 开启定时任务 TaskSchedulingAutoConfiguration
 *      可以设置 spring.task.scheduling.pool.size=5
 * @EnableAsync 开启异步任务 TaskExecutionAutoConfiguration
 *      spring.task.execution.pool.core-size=20
 *      spring.task.execution.pool.max-size=50
 *      spring.task.execution.pool.queue-capacity=50
 */
@Slf4j
//@Component
//@EnableScheduling
//@EnableAsync
public class HelloSchedule {

    /**
     * 默认定时任务是阻塞的。因为定时任务的线程池默认是1
     *
     * 让定时任务异步执行 使用@Async注解,
     * 使用 @Async+@Scheduled 来实现定时任务不阻塞
     */
//    @Async
//    @Scheduled(cron = "* * * * * *")
    public void hello(){
        log.info("hello,...");
    }
}
